<cfsetting enablecfoutputonly="yes" />
<!--- 
|| LEGAL ||
$Copyright: Daemon Pty Limited 1995-2003, http://www.daemon.com.au $
$License: Released Under the "Common Public License 1.0", http://www.opensource.org/licenses/cpl.php$

|| VERSION CONTROL ||
$Header: /cvs/farcry/farcry_mollio/www/go.cfm,v 1.1 2006/04/04 06:03:54 gstewart Exp $
$Author: gstewart $
$Date: 2006/04/04 06:03:54 $
$Name:  $
$Revision: 1.1 $

|| DESCRIPTION || 
$Description: Friendly URL interstitial file for processing friendly urls to parameterised urls $

|| DEVELOPER ||
$Developer: Guy Phanvongsa (guy@daemon.com.au) $
--->

<!--- TODO: using local invocation, move to factory scope when done --->
<cfif StructKeyExists(url,"path")>
	<cfset objFU = CreateObject("component","#application.packagepath#.farcry.fu")>
	
	<cfset returnFU.bSuccess = false />
	
	<cfset pathLen = ListLen(URL.path,'/') />
	<cfset urlPath = URL.path />

	<cfloop index="i" from="#pathLen#" to="2" step="-1">
		<cfset returnFU = objFU.fGetFUData(urlPath)>
		<cfif returnFU.bSuccess>
			<cfset URL.path = urlPath />
			<cfbreak />
		<cfelse>
			<cfset URL["param#i-2#"] = ListLast(urlPath, '/') />
			<cfset urlPath = ListDeleteAt(urlPath, i, '/') />
		</cfif>
	</cfloop>
	
	<cfif returnFU.bSuccess>
		<!--- check if this friendly url is a retired link.: if not then show page --->
		<cfif returnFU.redirectFUURL NEQ "">
			<cfheader statuscode="301" statustext="Moved permanently">
			<cfheader name="Location" value="#returnFU.redirectFUURL#">
			<cfabort>
		<cfelse>
			<cfset url.objectid = returnFU.refobjectid>
			<cfloop index="iQstr" list="#returnFU.query_string#" delimiters="&">
				<cfset url["#listFirst(iQstr,'=')#"] = listLast(iQstr,"=")>
			</cfloop>
	
			<cfinclude template="#application.url.conjurer#">
		</cfif>
	<cfelse>
		<cfinclude template="404.cfm">
	</cfif>
</cfif>

<cfsetting enablecfoutputonly="no" />